import axios from 'axios'
import { getToken } from './storage'
const request = axios.create({
  baseURL: 'http://liufusong.top:8080',
  timeout: 5000
})
// 请求拦截器
request.interceptors.request.use(
  function (config) {
    const token = getToken()
    if (token) {
      config.headers.Authorization = `${token}`
    }
    return config
  },
  function (err) {
    return Promise.reject(err)
  }
)
// 响应拦截器
request.interceptors.response.use(
  function (response) {
    return response.data
  },
  function (err) {
    return Promise.reject(err)
  }
)
export default request
